@import "../../styles/variables";
@import "../../styles/mixins";

label.radio {
  display: inline-block;
  position: relative;
  color: $dark-color07;
  & input[type="radio"] {
    margin: 0;
    outline: none !important;
    opacity: 0;
    visibility: hidden;
    cursor: pointer;
  }
  &:hover {
    &:not(.disabled) {
      &:before {
        background-color: $bg-color;
      }
      &:active {
        &:before {
          background-color: $light-color02;
        }
        &.checked:before {
          border-color: transparent;
          background-color: $primary;
        }
      }
    }
  }
  &:before {
    position: absolute;
    top: 2px;
    left: 0;
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px solid $border-color;
    border-radius: 100%;
    outline: none !important;
    background-color: #fff;
    box-shadow: inset 0 1px 2px 0 rgba(2, 5, 8, 0.08);
    line-height: 1.71;
    backface-visibility: hidden;
    transition: 0.2s ease;
    content: "";
    will-change: transform;
  }
  &.checked {
    &:before,
    &:hover:before {
      border: none;
      background-color: $primary;
      box-shadow: 0 1px 2px 0 rgba(0, 41, 27, 0.04);
    }
    &:after {
      position: absolute;
      top: 6px;
      left: 4px;
      display: inline-block;
      width: 6px;
      height: 6px;
      border-radius: 100%;
      outline: none !important;
      background-color: #fff;
      box-shadow: 0 1px 2px 0 rgba(0, 68, 36, 0.04);
      line-height: 1.71;
      backface-visibility: hidden;
      transition: 0.2s ease;
      content: "";
      will-change: transform;
    }
  }
  & > input {
    &[disabled] {
      border-color: $light-color01;
      color: $dark-color07;
      background-color: #fff !important;
      box-shadow: none;
      cursor: not-allowed;
    }
  }
  & > span.label-value {
    display: inline-block;
    vertical-align: middle;
    @include TypographyParagraph;
    color: inherit;
    padding: 0 8px;
    user-select: none;
  }
}

.radio + .radio {
  margin-left: 0;
}

label.radio.disabled {
  color: $dark-color07;
  opacity: 0.5;
  cursor: not-allowed;
}

.radio-group {
  display: inline-flex;

  label.radio {
    margin-right: 24px;
    &:last-child {
      margin-right: 0;
    }
  }

  label.radio-button {
    position: relative;
    height: 28px;
    padding: 4px 24px;
    transition: none;
    input {
      display: none;
    }
    &:focus {
      background-color: $btn-default-bg;
    }
    &:hover {
      background-color: $btn-default-hover-bg;
    }
    &:active {
      background-color: $btn-default-active-bg;
    }
    &.disabled {
      background-color: $btn-default-bg !important;
      opacity: 0.5;
      cursor: not-allowed;
    }
    &.checked {
      color: $btn-control-text-color;
      background-color: $btn-control-bg;
      z-index: 10;
    }

    span.label-value {
      display: block;
      height: 20px;
      line-height: 20px;
      text-align: center;
    }
  }

  .button + .button {
    margin-left: 0;
  }
}

.radio-group-button {
  padding: 1px;
  border-radius: 16px;
  background-color: $secondary-bg-color;
  border: 1px solid $border-color;
}
